Expression: Location Functions

These functions allow you to use latitude and longitude to calculate distance as well as selecting parts of UK postcodes

GeoDist

Calculates the straight line distance between two points. Latitude and longitude specified in decimal degrees. Optional Units parameter starts with m for miles (default) or k for km.

 

GeoDist(latitude1, longitude1, latitude2, longitude2, [units])

 

GeoDistMin

Returns distance to nearest point from reference point. Latitude and longitude specified in decimal degrees. Optional Units parameter starts with m for miles (default) or k for km.

 

GeoDistMin(referenceLatitude, referenceLongitude, latitude1, longitude1, latitude2, longitude2, ..., [Units])

 

GeoNearest

Returns index of point nearest to reference point. Latitude and longitude specified in decimal degrees. Index is 1-based.

 

GeoDist(referenceLatitude, referenceLongitude, latitude1, longitude1, latitude2, longitude2 ...)

 

UKPostcode

Returns position information for the middle point of a given UK postcode

 

UKPostcode("CV34 4EH", "Valid") returns 1

UKPostcode("CV34 4EH", "Latitude") returns 52.2813

UKPostcode("CV34 4EH", "Longitude") returns -1.5854

UKPostcode("CV34 4EH", "Easting") returns 428278

UKPostcode("CV34 4EH", "Northing") returns 264918

 

CV34 4EH is a valid postcode and has a latitude and longitude of 52.2813, -1.5854 and an Ordinance Survey all numeric grid reference of 428278,264918

 

UKPostcodeFormat

Returns part of a given UK postcode

 

UKPostcodeFormat("CV34 4EH", "Area") returns CV

UKPostcodeFormat ("CV34 4EH", "District") returns CV34

UKPostcodeFormat ("CV34 4EH", "Sector") returns CV34 4

UKPostcodeFormat ("CV34 4EH", "Outward") returns CV34

UKPostcodeFormat ("CV34 4EH", "Inward") returns 4EH

UKPostcodeFormat("CV34 4EH", "Postcode") returns CV34 4EH

 

UKPostcodeDistance

Returns the distance (in miles) between two UK postcodes

 

UKPostcodeDistance("CV34 4EH", "SW1A 1AA") returns 82.05

 

The distance between CV34 4EH and SW1A 1AA "as the crow flies" is 82.05 miles

 

UKPostcodeDistMin

Returns the distance (in miles) between the first, reference, UK postcode and the nearest other UK postcode specified

 

UKPostcodeDistMin("CV34 4EH", "SW1A 1AA","EH99 1SP", "CF99 1NA") returns 82.05

 

The distance between CV34 4EH and SW1A 1AA "as the crow flies" is 82.05 miles, between CV34 4EH and EH99 1SP is 261.81 miles and between CV34 4EH and CF99 1NA is 87.91 miles. Therefore 82.05 is the smallest distance

 

UKPostcodeNearest

Returns the index of the UK postcode that has the smallest distance between itself and the first, reference, UK postcode

 

UKPostcodeDistMin("CV34 4EH", "SW1A 1AA","EH99 1SP", "CF99 1NA") returns 1

 

The distance between CV34 4EH and SW1A 1AA "as the crow flies" is 82.05 miles, between CV34 4EH and EH99 1SP is 261.81 miles and between CV34 4EH and CF99 1NA is 87.91 miles. Therefore the first postcode after the reference postcode is the nearest